/*    */ package com.wzh.action.control.user;
/*    */ 
/*    */ import com.opensymphony.xwork2.ActionContext;
/*    */ import com.opensymphony.xwork2.ActionSupport;
/*    */ import com.wzh.bean.PageView;
/*    */ import com.wzh.bean.QueryResult;
/*    */ import com.wzh.bean.user.UserInfo;
/*    */ import com.wzh.service.user.UserService;
/*    */ import com.wzh.utils.MD5;
/*    */ import javax.annotation.Resource;
/*    */ import org.springframework.stereotype.Controller;
/*    */ 
/*    */ @Controller
/*    */ public class UserAction extends ActionSupport
/*    */ {
/*    */   private static final long serialVersionUID = 1L;
/*    */ 
/*    */   @Resource
/*    */   private UserService userService;
/*    */   private UserInfo user;
/* 23 */   private int page = 1;
/* 24 */   private String oldpwd = "";
/*    */ 
/*    */   public String getOldpwd()
/*    */   {
/* 29 */     return this.oldpwd;
/*    */   }
/*    */ 
/*    */   public void setOldpwd(String oldpwd) {
/* 33 */     this.oldpwd = oldpwd;
/*    */   }
/*    */ 
/*    */   public int getPage() {
/* 37 */     return this.page;
/*    */   }
/*    */ 
/*    */   public void setPage(int page) {
/* 41 */     this.page = page;
/*    */   }
/*    */ 
/*    */   public UserInfo getUser() {
/* 45 */     return this.user;
/*    */   }
/*    */ 
/*    */   public void setUser(UserInfo user) {
/* 49 */     this.user = user;
/*    */   }
/*    */ 
/*    */   public String index() {
/* 53 */     PageView pageView = new PageView(10, this.page);
/* 54 */     QueryResult qr = this.userService.getScrollData();
/* 55 */     pageView.setRecords(qr.getResultlist());
/* 56 */     pageView.setTotalrecords((int)qr.getTotalrecord());
/* 57 */     ActionContext.getContext().put("pageView", pageView);
/* 58 */     return "index";
/*    */   }
/*    */   public String edit() {
/* 61 */     this.user = ((UserInfo)this.userService.find(this.user.getId()));
/* 62 */     return "edit";
/*    */   }
/*    */ 
/*    */   public String update() {
/* 66 */     UserInfo oldUser = (UserInfo)this.userService.find(this.user.getId());
/* 67 */     if (!MD5.MD5Encode(this.oldpwd).equals(oldUser.getPassword())) {
/* 68 */       ActionContext.getContext().put("message", "旧密码错误");
/* 69 */       ActionContext.getContext().put("urladdress", "/control/user/edit?user.id=" + this.user.getId());
/*    */     } else {
/* 71 */       this.user.setPassword(MD5.MD5Encode(this.user.getPassword()));
/* 72 */       this.userService.update(this.user);
/* 73 */       ActionContext.getContext().put("message", "修改成功");
/* 74 */       ActionContext.getContext().put("urladdress", "/control/user/index");
/*    */     }
/* 76 */     return "message";
/*    */   }
/*    */ }

/* Location:           C:\work\apache-tomcat-7.0.55\webapps\ROOT\WEB-INF\classes\
 * Qualified Name:     com.wzh.action.control.user.UserAction
 * JD-Core Version:    0.6.1
 */